//
//  DYZRandomColorController.m
//  DYZCars
//
//  Created by xmy on 16/8/20.
//  Copyright © 2016年 MF. All rights reserved.
//

#import "DYZRandomColorController.h"
#import "Masonry.h"
#import "UIColor+Addition.h"
#import "QuartzCore/QuartzCore.h"

@interface DYZRandomColorController ()
@property(nonatomic,weak)UITextField *textFiled;

@end

@implementation DYZRandomColorController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //右侧保存按钮
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(saveClick)];
    self.navigationItem.rightBarButtonItem = item;
    
    [self leftButton];
    [self setupUI];

}

//左侧返回按钮
- (void)leftButton{
    //左侧返回按钮
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    // 为返回按钮设置图片样式
    [button setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    //按钮的点击事件
    [button addTarget:self action:@selector(popController) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.leftBarButtonItem = backButton;
    
    //将返回按钮的文字position设置不在屏幕上显示
    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin, NSIntegerMin) forBarMetrics:UIBarMetricsDefault];
}
//左侧按钮点击事件
- (void)popController{
    
    [self.navigationController popViewControllerAnimated:YES];
}

//保存按钮事件
- (void)saveClick{
    
    //跳转到寻车详情
    
}

- (void)setupUI{
    
    self.view.backgroundColor = [UIColor whiteColor];

    UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"input-1"]];
    
    [self.view addSubview:imageView];
    
    UITextField *text = [[UITextField alloc]init];
    
    [imageView addSubview:text];
    
    self.textFiled = text;
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(74);
        make.left.offset(10);
        make.right.offset(-10);
        make.height.offset(45);
    }];
    [text mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(imageView);
    }];

    switch (self.flag) {
        case 0:
            text.placeholder = @"请输入颜色";
            self.navigationItem.title = @"自定义外观颜色";
            break;
            
        case 1:
            text.placeholder = @"请输入颜色";
            self.navigationItem.title = @"自定义内饰颜色";
            break;
        case 2:
            text.placeholder = @"请输入区域";
            self.navigationItem.title = @"自定义区域";
            break;
        case 3:
            text.placeholder = @"请输入有效期";
            self.navigationItem.title = @"自定义有效期";
            break;
            
        default:
            break;
    }
    
}

@end
